package controllers

import (
	"github.com/gin-gonic/gin"
	"github.com/zw2582/ginlib"
	"net/http"
	"szxf/models"
	"szxf/services"
)

//服务已下架
func Phone2Check(c *gin.Context)  {
	this := ginlib.Context{c}
	accountId := this.InputInt("account_id")
	name := this.InputStr("name")
	phone := this.InputStr("phone")
	sign := this.InputStr("sign")

	//验证ip
	if rc := models.ValidAccountIp(accountId, this.ClientIP()); rc != nil {
		this.JSON(http.StatusOK, gin.H{
			"code":rc,
			"uuid":ginlib.OrderNo(""),
			"msg":rc.Desc(),
		})
		return
	}

	//解析结果
	server := services.NewPhone2Service(accountId, name, phone, sign)
	rc := server.Check()

	this.JSON(http.StatusOK, gin.H{
		"uuid":server.LogReq.Uuid,
		"code":rc,
		"msg":rc.Desc(),
		"data":"",
	})
}

func Phone3Check(c *gin.Context)  {
	this := ginlib.Context{c}
	accountId := this.InputInt("account_id")
	name := this.InputStr("name")
	phone := this.InputStr("phone")
	idCardNo := this.InputStr("id_card_no")
	sign := this.InputStr("sign")

	//验证ip
	if rc := models.ValidAccountIp(accountId, this.ClientIP()); rc != nil {
		this.JSON(http.StatusOK, gin.H{
			"code":rc,
			"uuid":ginlib.OrderNo(""),
			"msg":rc.Desc(),
		})
		return
	}

	//解析结果
	server := services.NewPhone3Service(accountId, name, phone, idCardNo, sign)
	rc := server.Check()

	this.JSON(http.StatusOK, gin.H{
		"uuid":server.LogReq.Uuid,
		"code":rc,
		"msg":rc.Desc(),
		"data":"",
	})
}